import type { ListDataI, ListParams } from '@/types'
import type {
  EnRentBuildingI,
  BusinessLicenseI,
  EnAddParamsI,
  EnDetailI,
  EnEditParamsI,
  enListData,
  enListParams,
  IndustryI,
  EnRentParamsI,
  EnRentI,
  BuildingI,
} from '@/types/park.d.ts'
import { http } from '@/utils/reuqest'

/**
 * 获取企业列表
 */
export const parkGetEnListApi = (params: enListParams) => {
  return http.get<enListData>('park/enterprise', params)
}
/**
 * 获取行业列表
 */
export const parkGetIndustryListApi = () => {
  return http.get<IndustryI[]>('park/industry')
}
/**
 * 获取营业执照
 */
export const parkGetBusinessLicenseApi = (data: FormData) => {
  return http.post<BusinessLicenseI>('upload', data)
}
/**
 * 增加企业
 */
export const parkAddEnApi = (data: EnAddParamsI) => {
  return http.post<null>('park/enterprise', data)
}
/**
 * 获取企业详情
 */
export const parkGetEnDetailApi = (id: string) => {
  return http.get<EnDetailI>(`park/enterprise/${id}`)
}
/**
 * 编辑企业
 */
export const parkEditEnApi = (data: EnEditParamsI) => {
  return http.put<null>('park/enterprise', data)
}
/**
 * 删除企业
 */
export const parkDelEnApi = (id: string) => {
  return http.delete<null>(`park/enterprise/${id}`)
}
/**
 * 获取可租赁楼宇列表
 */
export const parkGetRentBuildingListApi = () => {
  return http.get<EnRentBuildingI[]>('park/rent/building')
}
/**
 * 添加/续约租赁合同
 */
export const parkEnRentApi = (data: EnRentParamsI) => {
  return http.post<null>('park/enterprise/rent', data)
}
/**
 * 获取企业租赁信息列表
 */
export const parkGetEnRentListApi = (id: number) => {
  return http.get<EnRentI[]>(`park/enterprise/rent/${id}`)
}
/**
 * 退租租赁合同
 */
export const parkEnOutRentApi = (id: number) => {
  return http.put(`park/enterprise/rent/${id}`)
}
/**
 * 删除租赁合同
 */
export const parkDelRentApi = (id: number) => {
  return http.delete(`park/enterprise/rent/${id}`)
}
/**
 * 下载合同
 */
export const parkDownloadContractApi = (id: number) => {
  return http.get<Blob>(`download/${id}`, {}, { responseType: 'blob' })
}
/**
 * 查询楼宇
 */
export const buildingGetApi = (params: ListParams) => {
  return http.get<ListDataI<BuildingI>>('park/building', params)
}
/**
 * 新增楼宇
 */
export const buildingAddApi = (data: BuildingI) => {
  return http.post<null>('park/building', data)
}
/**
 * 修改楼宇
 */
export const buildingEditApi = (data: BuildingI) => {
  return http.put<null>('park/building', data)
}
/**
 * 删除楼宇
 */
export const buildingDelApi = (id: number) => {
  return http.delete<null>(`park/building/${id}`)
}
